package com.liyang.nacos;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @version 1.0
 * @Title: Service1Bootstrap
 * @description TODO
 * @date 2021/4/24 0024 14:26
 */

@RestController
@RefreshScope  //加这个的地方才动态刷新
@SpringBootApplication
public class Service1Bootstrap {
    public static void main(String[] args) {
        SpringApplication.run(Service1Bootstrap.class, args);

    }
    @Autowired
    private ApplicationContext  applicationContext;

    @Value("${common.name}")
    private String config1;

    @GetMapping("/configs")
    public String getConfig() {
        return config1;
        //这种方式也动态刷新
        // return applicationContext.getEnvironment().getProperty("common.name");


    }

}